<!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
		<link rel="stylesheet" type="text/css" href="../../css/aui.css" />

    <style>

        #header_top {
            background: #2997e4;
            padding-top: 25px;
        }
     .aui-tab{
        background: none
     }
     .aui-tab-item{
       background: none;
       color: #fff
     }
     .aui-tab-item.aui-active {
          color: #ffffff;
          font-weight: bold;
          border-bottom: 2px solid #039be5;
      }
      .aui-bar-nav .aui-title{
        right: 2rem;
        left: 2rem;
      }
    </style>
  </head>
  <body>
    <div id="wrap">
      <header id="header_top" class="aui-bar aui-bar-nav" >

        <a class="aui-pull-left"  onclick="goback()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">
        <div class="aui-tab" id="tab" style="width:100%">
          <div class="aui-tab-item aui-active">期刊</div>
          <div class="aui-tab-item"><div></div>书城</div>

        </div>
      </div>
    	</header>
    </div>
  </body>
  <script type="text/javascript" src="../../script/api.js"></script>
  <script type="text/javascript" src="../../script/aui-tab.js"></script>
  <script type="text/javascript">
    function goback () {
      api.closeWin();

    }

    function openSearch(type, cid) {
      api.openWin({
      name: 'search',
      url: '../search.html',
      bounces: false,
      pageParam: {
        type: type,
        cid: cid
      },
      delay:200
      });
    }

    function closeFrame(){
      for(var i=0;i<=3;i++){
        //api.closeWin({name:'index_xs'+i});
      }
      api.closeWin({name:api.pageParam.name});
    }
  	function openDetail(index) {

      var header_top = $api.byId('header_top');
  		var header_topPos = $api.offset(header_top);



      api.openFrame({
  			name: 'index_wx' + index,
  			pageParam: {
    			name: 'index_wx' + index
  			},
        rect:{
          x:0,
          y:header_topPos.h,
          w:'auto',
          h:api.frameHeight - header_topPos.h
        },
  			url: './'+'index_wx' + index+'.html',
  			delay: 200,
  			bounces: false,
        scrollEnabled: true,
        opaque: false
  		});
  	}

    // 完成首页初始化
    apiready = function(){


      var header_top = $api.byId('header_top');
  		var header_topPos = $api.offset(header_top);
      $api.fixStatusBar(header_top);

      var type = api.pageParam.name;

        api.openFrame ({
            name: type,
            url: './'+type+'.html',
            rect:{
                x:0,
                y:header_topPos.h,
                w:'auto',
                h:'auto'
            },
            bounces: false,
            delay:200
        })



        var pageIndex = type[type.length - 1]
        var lis = $api.domAll('#title ul li')
        var curLi = lis[pageIndex]
        $api.addCls(curLi,'active')
    };

    var tab = new auiTab({
          element:document.getElementById("tab"),
          callback:function(o,dom){


          },
  				repeatClick:false
      },function(ret){
          // console.log(ret)
          openDetail(ret.index-1)
      });
  </script>
</html>
